#!/bin/bash

echo "🔍 开始诊断容器状态..."

# 1. 检查容器状态
echo "📊 容器状态："
docker compose ps

echo ""
echo "📋 容器日志："
docker compose logs --tail=20

echo ""
echo "🔧 检查端口映射："
docker port cyjw-web

echo ""
echo "📁 检查 SSL 证书："
if [ -d "ssl" ]; then
    echo "SSL 目录存在"
    ls -la ssl/
else
    echo "❌ SSL 目录不存在"
fi

echo ""
echo "🌐 测试容器内连接："
echo "测试 HTTP (容器内端口 80)："
docker exec cyjw-web curl -I http://localhost:80 2>/dev/null || echo "❌ HTTP 连接失败"

echo ""
echo "测试 HTTPS (容器内端口 443)："
docker exec cyjw-web curl -I https://localhost:443 2>/dev/null || echo "❌ HTTPS 连接失败"

echo ""
echo "🔍 检查 Nginx 配置："
docker exec cyjw-web nginx -t 2>&1

echo ""
echo "📝 检查 Nginx 进程："
docker exec cyjw-web ps aux | grep nginx

echo ""
echo "🌐 外部访问测试："
echo "HTTP: http://localhost:8880"
echo "HTTPS: https://localhost:8443" 